using System;
using System.Data;

namespace Serpis
{
	[System.ComponentModel.ToolboxItem(true)]
	public partial class My_TreeView : Gtk.Bin
	{
		// Declaramos el evento privado Cambio
		public event EventHandler Changed;
		
		public TreeViewHelper treeViewHelper;
		
		public My_TreeView ()
		{
			this.Build ();
		}
		public void Init(IDbConnection dbConnection, string commandText)
		{
			treeViewHelper = new TreeViewHelper(treeView, dbConnection, commandText);
			
			treeViewHelper.Changed += delegate
			{
				raisedChanged();
			};
		}
		
		private void raisedChanged()
		{
			if(Changed != null)
			{
				Changed(this, EventArgs.Empty);
				Console.WriteLine("Evento detectado desde el My_TreeView");
			}
		}
		public void Refresh() 
		{
			treeViewHelper.Refresh();
		}
		public TreeViewHelper TreeViewHelper 
		{
			get {return this.treeViewHelper;}
			set {treeViewHelper = value;}
		}
		public string GetValue(int columnIndex) 
		{
			return treeViewHelper.GetValue(columnIndex);
		}
	}
}

